﻿$(document).ready(function() {
	/// TABS ///
	// profile:
	$( "#profile_tabs" ).tabs({
	    select: function(event, ui) {
	        $('form#records-options').attr('action', '#' + ui.panel.id);
	        return true;
	    }
	});
	
	
	//pour activer l'effet de transparence des labels
	$(".absoluteLabel label").inFieldLabels();

	//// SUBMIT FORM ////
	
	// [submit form] init
	updateForType(0);
	updateForMode(0);
	updateForNegativeTime();
	
	// [submit form] events
	$('#typeForm').click(function() {
		updateForType();
	}); 
	$('#modeForm').click(function() {
		updateForMode();
	}); 
	$("#negativeTimeForm").click(function() {
		updateForNegativeTime();
	}); 
	
	// [submit form] show/hide functions
	function updateForType(speed){
		var speed = speed || 200;
		if($("#typeForm input[value=4]:checked").length){ // if relic
			$('.relicOption').slideDown(speed);
			$('#label_cheated, #cheatsForm').slideUp(speed);
			$("#label_cheated input:checked").removeAttr("checked");
			$("#label_classic input").attr("checked", "checked");
		}
		else{
			$('.relicOption').slideUp(speed);
			$('#label_cheated').slideDown(speed);
			updateForMode(speed);
		}
	}
	
	function updateForMode(speed){
		var speed = speed || 200;
		if($("#label_classic input:checked").length){ // if classic
			$('#cheatsForm').slideUp(speed);
		}
		else{
			$('#cheatsForm').slideDown(speed);
		}
	}
	
	function updateForNegativeTime(){
		if($("#negativeTimeForm input:checked").length){ // if negative time
			$('.onNegativeTime').fadeIn();
		}
		else{
			$('.onNegativeTime').fadeOut();
		}
	}
	// end [submit form]
	
	// Ranking tooltip
	$('.ranking_block')
		.mouseenter(function(){
			$(this).find('.extra-infos').css('visibility','visible');
		}).mouseleave(function(){
			$(this).find('.extra-infos').css('visibility','hidden');
		});
});